package easy;

public class Solution_2022 {

    public int[][] construct2DArray(int[] original, int m, int n) {
        if (n * m != original.length) {
            return new int[0][];
        }
        int[][] ints = new int[m][n];
        for (int i = 0, r = -1, c = 0; i < original.length; i++) {
            if (c % n == 0) {
                r++;
                c = 0;
            }
            ints[r][c++] = original[i];
        }
        return ints;
    }
}
